using System;
using System.Configuration;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.Security;

namespace Starznet.SharePoint.SPDAT.ApplicationPages.Settings
{
    public class MembershipLoginPage : LayoutsPageBase
    {
        protected TextBox TxtLoginPage;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Configuration oSourceConfig =
                WebConfigurationManager.OpenWebConfiguration("/");
            AuthenticationSection oAuthSection = (AuthenticationSection)oSourceConfig.GetSection("system.web/authentication");

            TxtLoginPage.Text = oAuthSection.Forms.LoginUrl;
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            Configuration oSourceConfig =
                WebConfigurationManager.OpenWebConfiguration("/");
            AuthenticationSection oAuthSection = (AuthenticationSection)oSourceConfig.GetSection("system.web/authentication");

            oAuthSection.Forms.LoginUrl = this.TxtLoginPage.Text;
            oSourceConfig.Save();

            Response.Redirect(SPContext.Current.Site.Url + "/_layouts/settings.aspx");
        }
    }
}